home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT29.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  3.2 KB  |  89 lines

  1. /*
  2. ==============================================================================
  3.               WordUp Graphics Toolkit Version 5.0                     
  4.                  Demonstration Program 29                         
  5.                                           
  6.  Demonstrate the use of wcopyscreen to simulate a text scroller.             
  7.                                          
  8.  *** PROJECT ***                                                             
  9.  This program requires the file WGT5_WC.LIB to be linked.                    
  10.                                           
  11.  *** DATA FILES ***                                                          
  12.  Make sure that LETTERS.SPR is in your executable directory.                 
  13.                                WATCOM C++ VERSION 
  14. ==============================================================================
  15. */
  16.  
  17. #include <dos.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <conio.h>
  21. #include <wgt5.h>
  22.  
  23. color p[256];                 /* Our palette */
  24. block sprites[1001];          /* Pointers to blocks */
  25.  
  26.  
  27. void main(void)
  28. {
  29.   char *scrolltext="THIS IS A SMALL TEXT SCROLLER CREATED WITH THE WCOPYSCREEN COMMAND.  PRESS A KEY TO END THIS SCROLLER...    ";
  30.  
  31.   short scrnum;                   /* Counter for current letter of scroller */
  32.   short nextlet, i, j, k;         /* Counters */
  33.   short oldmode;                  /* Stores intial video mode */
  34.  
  35.   if ( !vgadetected () )
  36.   {
  37.     printf("Error - VGA card required for any WGT program.\n");
  38.     exit (0);
  39.   }
  40.   printf ("WGT Example #29\n\n");
  41.   printf ("Virtual screens are used to create a tickertape scroller on the bottom of\n");
  42.   printf ("the visual screen. Press a key to end the program at any time.\n");
  43.   printf ("\n\nPress any key to continue.\n");
  44.   getch ();
  45.  
  46.  
  47.   oldmode = wgetmode ();         /* Gets the current mode */
  48.   vga256 ();                     /* Initialize graphics mode */
  49.  
  50.   wloadsprites (p, "letters.spr", sprites, 0, 1000); /* Load our blocks */
  51.  
  52.   for (i = 0; i < 180; i++)      /* Draws a background for the screen */
  53.   {
  54.     wsetcolor (i);
  55.     wline (0, 0, 319, i);
  56.     wline (319, 199, 0, 180 - i);
  57.   }
  58.  
  59.   wsetcolor (0);                    /* Draw with black */
  60.   wbar (0, 189, 319, 199);          /* Clear area off bottom for scroller */
  61.   do
  62.   {
  63.     scrnum = 0;           /* Start at first character of scroller string */
  64.     do
  65.     {
  66.       /* Find pixel width of current letter in string */
  67.       nextlet = wgetblockwidth (sprites[scrolltext[scrnum] + 1]);
  68.       for (j = 0; j <= nextlet + 1; j += 2)
  69.       {
  70.     wbar (318, 189, 319, 199);  /* Erase right-hand side of scroller area */
  71.  
  72.     /* Now copy the last letter on at the end of the string */
  73.     wputblock (319 - j, 189, sprites[scrolltext[scrnum] + 1], 0);
  74.  
  75.     /* Wait for monitor to finish vertical retrace */
  76.     wretrace ();
  77.  
  78.     /* Shift scroller to the left */
  79.     wcopyscreen (2, 189, 319, 199, NULL, 0, 189, NULL);
  80.       }
  81.       scrnum++;                                 /* Advance to next letter */
  82.     } while ((scrolltext[scrnum + 1] != 0) & (!kbhit ()));
  83.      /* Loop yet? */
  84.   } while (!kbhit ());                          /* Abort if key pressed */
  85.  
  86.   wfreesprites (sprites, 0, 1000);              /* Free our sprites */
  87.   wsetmode (oldmode);                    /* Restore initial video mode */
  88. }
  89.